package com.wdl.fmnew.app.demo;

import com.wdl.fmnew.core.net.callback.ApiListener;

import java.util.List;

import javax.inject.Inject;

/**
 * Created by wdl on 2017/9/18.
 */

public class DemoPresenter implements DemoContract.Presenter {
    private DemoContract.View view;

    @Inject
    DemoModel demoModel;

    @Inject
    public DemoPresenter() {

    }

    @Override
    public void takeView(DemoContract.View view) {
        this.view = view;
    }

    @Override
    public void dropView() {
        this.view = null;
        demoModel.release();
    }

    @Override
    public void refreshData() {
        demoModel.getData(new ApiListener<String>() {
            @Override
            public void onSucess(List<String> datas) {
                view.showTip("get data success");
            }

            @Override
            public void onError(Throwable throwable, String msg) {
                super.onError(throwable, msg);
                view.showTip(msg);
            }
        });

    }

    @Override
    public void mn() {
        demoModel.mn();
    }
}

